package org.hypnus.e.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTag;

import org.hypnus.e.util.EConstants;
import org.hypnus.e.util.TagType;
import org.hypnus.e.util.TagUtil;

public class PaginationTag extends AbstractTag {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String grid ;
	
	public PaginationTag() {
		super();
		super.type = TagType.PAGINATION ;
	}
	
	

	private int pageSize =50 ;
	
	private int pageNo =0 ;
	
	private int total ; 
	
	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	
	
	
	public String getGrid() {
		return grid;
	}

	public void setGrid(String grid) {
		this.grid = grid;
	}

	@Override
	public int doStartTag() throws JspException {
		TagUtil tagUtil = TagUtil.getInstance() ;
//		for(int i= 0 ;i<10000 ;i++){
			StringBuilder builder = tagUtil.prepareAttribute(this, EConstants.DIV);
			tagUtil.write(pageContext, builder.toString()) ;
//		}
		
		return BodyTag.EVAL_BODY_INCLUDE;
	}

	@Override
	public int doEndTag() throws JspException {
//		TagUtil tagUtil = TagUtil.getInstance() ;
//		EDataset dataset = tagUtil.getEContext(pageContext).getDst(this.getDataset()) ;
//		EGrid eGrid = dataset.getGrid(this.getId())==null?new  EGrid(): dataset.getGrid(this.getId());
//		eGrid.setPageSize(this.getPageSize()) ;
//		eGrid.setPageNo(this.getPageNo()) ;
//		eGrid.setTotal(this.getTotal()) ;
		return BodyTag.EVAL_PAGE;
	}
	
	
}
